package com.miukoo.aikao.ucenter.controller.v1;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.miukoo.aikao.core.dtos.ApiResult;
import com.miukoo.aikao.core.dtos.PageReqDto;
import com.miukoo.aikao.core.dtos.PageResDto;
import com.miukoo.aikao.core.utils.ApiUtils;
import com.miukoo.aikao.core.utils.AppUserUtils;
import com.miukoo.aikao.ucenter.dto.request.AchievementReqDto;
import com.miukoo.aikao.ucenter.dto.response.AchievementRespDto;
import com.miukoo.aikao.ucenter.services.AchievementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
　* 用户成绩列表
　* @Author miukoo<miukoo@126.com>
　* @Date 2020/11/19 19:25
　* @Version 1.0
  */
@Api(tags={"用户成绩列表"})
@RestController
@RequestMapping("/ucenter/achievement/v1")
public class AchievementController {

    @Autowired
    private AchievementService achievementService;

    /**
    * 分页查找用户成绩
    * @param reqDto
    * @return
    */
    @ApiOperation(value = "分页查找")
    @RequestMapping(value = "/list", method = { RequestMethod.POST})
    public ApiResult<PageResDto<List<AchievementRespDto>>> listAchievementForUser(@RequestBody PageReqDto<AchievementReqDto> reqDto) {

        Long userId = AppUserUtils.getUser().getId();
        //分页查询并转换
        PageResDto<List<AchievementRespDto>> listPageResDto = achievementService.listForUserId(reqDto, userId);

        return ApiUtils.success(listPageResDto);
    }
}
